package io.bdmc.modules.bss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.bdmc.common.annotation.DataFilter;
import io.bdmc.common.utils.MyPage;
import io.bdmc.modules.bss.entity.DeviceAlarmMask;
import io.bdmc.modules.bss.mapper.DeviceAlarmMaskMapper;
import io.bdmc.modules.bss.model.DeviceAlarmMaskParam;
import io.bdmc.modules.bss.service.IDeviceAlarmMaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 设备报警 服务实现类
 * </p>
 *
 * @author ping
 * @since 2020-07-01
 */
@Service
public class DeviceAlarmMaskServiceImpl extends ServiceImpl<DeviceAlarmMaskMapper, DeviceAlarmMask> implements IDeviceAlarmMaskService {
    @Autowired
    DeviceAlarmMaskMapper _maskMapper;

    @DataFilter(tableAlias = "d")
    @Override
    public MyPage<DeviceAlarmMask> mySelectPage(MyPage<DeviceAlarmMask> myPage, DeviceAlarmMaskParam params) {
        return _maskMapper.mySelectPage(myPage, params);
    }

    @Override
    public boolean isAlarmMask(String deviceSn, String alarmTypeCode) {
        QueryWrapper<DeviceAlarmMask> w1 = new QueryWrapper<>();
        w1.eq("device_sn",deviceSn).eq("alarm_type_code",alarmTypeCode);
        long count = count(w1);
        return count>0;
    }

}
